/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mygame.procedural.ik;

import mygame.procedural.ik.IkControl;
import com.jme3.animation.Bone;
import com.jme3.animation.Skeleton;
import com.jme3.scene.Node;

/**
 *
 * @author Paulo
 */
public class LimbIkControl extends IkControl {
    //Any local variables should be encapsulated by getters/setters so they
    //appear in the SDK properties window and can be edited.
    //Right-click a local variable to encapsulate it with getters and setters.

    private Bone ikBone;
    private Bone ikTarget;
    private Node target;
    
    public LimbIkControl(Skeleton skeleton, String ikBone, String ikTarget, int chainLength, Node target) {
        super(skeleton);
        this.ikBone = skeleton.getBone(ikBone);
        this.ikTarget = skeleton.getBone(ikTarget);
        this.target = target;
        this.target.setLocalTranslation(this.ikTarget.getWorldBindPosition().clone());
        
        this.setFirstBone(this.ikBone);
        this.setTargetBone(this.ikTarget);
        this.setMaxChain(chainLength);
        this.setTarget(target);
        
        //this.skeleton.reset();
        //this.skeleton.updateWorldVectors();
    }
}
